/*
 * @Author: 陈德基
 * @Date: 2021-11-15 17:12:00
 * @LastEditTime: 2021-11-16 20:08:54
 * @Description: 
 * @FilePath: \copy_gsy_github_app_flutter\lib\common\net\address.dart
 * 联系方式：
 * wx: melody_2009
 * qq: 7815171323 
 */

import 'package:copy_gsy_github_app_flutter/common/config/config.dart';
import 'package:copy_gsy_github_app_flutter/common/config/ignoreConfig.dart';

class Address {
  static const String host = "https://api.github.com/";
  static const String hostWeb = "https://github.com/";
  static const String graphicHost = 'https://ghchart.rshah.org/';
  static const String updateUrl =
      'https://gitee.com/CarGuo/GSYGithubAppFlutter/releases';

  static getOAuthUrl() {
    return "https://github.com/login/oauth/authorize?client_id"
        "=${NetConfig.CLIENT_ID}&state=app&"
        "redirect_uri=gsygithubapp://authed";
  }

  ///我的用户信息 GET
  static getMyUserInfo() {
    return "${host}user";
  }

  static getUserInfo(userName) {
    return "${host}users/$userName";
  }

  static userStar(userName, sort) {
    sort ??= 'updated';
    return "${host}users/$userName/starred?sort=$sort";
  }

  ///用户收到的事件信息 get
  static getEventReceived(userName) {
    return "${host}users/$userName/received_events";
  }

  ///处理分页参数
  static getPageParams(tab, page, [pageSize = Config.PAGE_SIZE]) {
    if (page != null) {
      if (pageSize != null) {
        return "${tab}page=$page&per_page=$pageSize";
      } else {
        return "${tab}page=$page";
      }
    } else {
      return "";
    }
  }
}
